<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="./WSclient.js"></script>
    <script>
        // if ('WebSocket' in window) {
        // }



        const socket = new WSclient(`ws://127.0.0.1:3001`);

        // const socket = new WSclient({
        //     url: `ws://127.0.0.1:3001`,
        //     reconnection: true,//断线重连
        //     reconnectionAttempts: 3,//重连次数
        //     reconnectionDelay: 1000,// 重连延时,1秒后尝试
        //     autoConnect: true,//创建自动连接
        // });

        // socket.connect();//手动连接

        socket.on('open', function (event) {
            console.log("连接成功！！")
            socket.send('Hello Server!');
        });
        socket.on('close', function (event) {
            console.log('关闭连接')
        });

        socket.on('message', function (event) {
            console.log('信息:', event.data);
        });

    </script>
</body>

</html>